<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>替换 a 为 the</title>
</head>
<body>
<script>
    var myString = 'a dog walked in off a street and ordered a finest beer';
    var myRegExp = /\ba\b/gi;
    myString = myString.replace(myRegExp, 'the');
    document.write(myString);
</script>
</body>
</html>